package rule

import (
	"strings"
)

type Ruler interface {
	Verify(source string, target string) bool
}

type IncludeRule struct {
}

func (r *IncludeRule) Verify(source string, include string) bool {
	return strings.Contains(source, include)

}

type ExcludeRule struct {
}

func (r *ExcludeRule) Verify(source string, include string) bool {
	return !strings.Contains(source, include)
}

type EqualsRule struct {
}

func (r *EqualsRule) Verify(source string, include string) bool {
	return source == include
}

type NeqRule struct {
}

func (r *NeqRule) Verify(source string, include string) bool {
	return source != include
}

type Factory struct {
	Rule string
}

func (f *Factory) GetRule() Ruler {
	if f.Rule == "include" {
		return &IncludeRule{}
	} else if f.Rule == "exclude" {
		return &ExcludeRule{}
	} else if f.Rule == "equals" {
		return &EqualsRule{}
	} else if f.Rule == "neq" {
		return &NeqRule{}
	}
	return nil
}
